<?php

namespace App\Models\Applet\Shop;

class ShopCategoryModel extends BaseShopModel
{
    protected $table = 'shop_category';

    /**
     * 总条数
     * @param array $params
     * @return int
     */
    public function total(array $params): int
    {
        return $this->where('deleted', self::DELETED_NO)
                    ->count();
    }

    /**
     * 商品分类列表
     * @return void
     */
    public function list(array $params, array $fields = self::QUERY_DEFAULT_FIELDS)
    {
        return $this->select($fields)
                    ->where('deleted', self::DELETED_NO)
                    ->orderBy('id', 'asc')
                    ->offset((CURRENT_PAGE - 1) * PAGE_SIZE)
                    ->limit(PAGE_SIZE)
                    ->get()
                    ->toArray();
    }
}
